<template>
	<view class="member-block">
		<template v-if="list.length>0">
			<view class="user-block" v-for="item in list" :key="item.id">
				<view class="user-top">
					<view class="user-item">
						<image :src="cloudStorage+item.faceUrl" mode=""></image>
						<view class="username">
							<view class="user-title">{{item.name}}</view>
							<view class="phone">{{item.phone}}</view>
							<view class="phone" v-if="item.vip==1" style="color: aquamarine;">已成为会员</view>
							<view class="phone" v-if="item.vip==2" style="color: #FF2F34;">暂未成为会员</view>
						</view>
					</view>
				</view>
			</view>
		</template>
		<view v-if="more==false&&list.length==0" style="width:100%;text-align: center;">暂无数据</view>
		<view v-else-if="more==false&&list.length>0" style="width:100%;text-align: center;">没有更多了</view>
	</view>
</template>

<script>
	import {
		getUserInviteRecordList
	} from '@/api/mine.js'
	import {
		isMore
	} from '@/util/util.js'
	export default {
		data() {
			return {
				conf: {
					page: 1,
					limit: 10,
				},
				more: true,
				list: [],
			}
		},
		methods: {
			handleRefresh() {
				this.conf.page = 1;
				this.more = true
				uni.showLoading({
					title: '加载中',
					mask: true
				})
				this.getList(true)
			},
			getList(refresh = false) {
				uni.showLoading({
					title: '加载中',
					mask: true
				})
				getUserInviteRecordList({
					page: this.conf.page,
					limit: this.conf.limit,
					keyword: this.keyword,
				}).then((res) => {
					let list = res.records || [];
					if (refresh) {
						this.list = list;
					} else {
						this.list = [...this.list, ...list]
					}
					this.more = isMore(this.conf.page, this.conf.limit, res.total)
					this.fans = res.fansCount
					this.sumIncomeIntegral = res.sumIncomeIntegral
				})
			},
		},
		onPullDownRefresh() {
			this.handleRefresh();
		},
		onReachBottom() {
			if (this.more) {
				this.conf.page++;
				uni.showLoading({
					title: '加载中',
					mask: true
				})
				this.getList();
			}
		},
		onLoad() {
			this.getList(true)
		}
	};
</script>

<style lang="scss" scoped>
	.member-block {
		padding: 30rpx;

		.user-block {
			width: 100%;
			padding: 30rpx;
			border-radius: 20rpx;
			background-color: #FFFFFF;
			margin-bottom: 30rpx;

			.user-top {
				display: flex;
				align-items: center;
				justify-content: space-between;
				margin-bottom: 30rpx;

				.user-item {
					display: flex;
					align-items: center;

				}

				image {
					width: 130rpx;
					height: 130rpx;
					border-radius: 50%;
					margin-right: 20rpx;
				}

				.username {
					display: flex;
					flex-direction: column;
					justify-content: space-around;

					.user-title {
						//margin-bottom: 10rpx;
					}

					.phone {
						font-size: 12px;
						font-weight: normal;
						letter-spacing: 0em;
						color: #767676;
						margin-top: 20rpx;
					}
				}

				.accounts {
					background-color: #FF2F34;
					color: #fff;
					font-size: 30rpx;
					padding: 6rpx 16rpx;
					border-radius: 10rpx;
				}
			}
		}
	}
</style>